# -*- coding: utf-8 -*-
"""part3: 日志系统， 发布-订阅"""

import pika
import sys

connection = pika.BlockingConnection(
    pika.ConnectionParameters(
        host='172.22.23.252'
    ))

channel = connection.channel()

channel.exchange_declare(exchange='logs',
                         exchange_type='fanout')

message = ''.join(sys.argv[1:]) or "info: Hello World!"
channel.basic_publish(exchange='logs',
                      routing_key='',
                      body=message)

print("[x] Sent %r" % message)
connection.close()




